package com.wsl.encry.ui;

import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.util.NlsContexts.ConfigurableName;
import com.wsl.encry.MyPluginState;
import javax.swing.JComponent;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;

public class UIClass implements Configurable {

	private config config;
	private MyPluginState state= MyPluginState.getInstance().getState();

	@Nls(capitalization = Nls.Capitalization.Title)
	@Override
	public @ConfigurableName String getDisplayName() {
		return "EncryptionSettings";
	}

	@Override
	public @Nullable JComponent createComponent() {
		config = new config();
		if(MyPluginState.getInstance().getState()!=null){
			config.getKeyValue().setText(MyPluginState.getInstance().getState().getKey());

		}
		return config.getMain();
	}

	@Override
	public boolean isModified() {
		return true;
	}

	@Override
	public void apply() throws ConfigurationException {
		// 实现这个方法来保存设置
		System.out.println("apply");
		state.setKey(config.getKeyValue().getText());
	}

//	@Override
//	public void reset() {
//		// 实现这个方法来重置设置
//	}
}
